import threading
import time
import numpy as np
ev=threading.Event()

# ev.set()
# ev.clear()
# ev.wait()

def flag():
    time.sleep(3)
    ev.set()
    print('start count down')
    time.sleep(7)
    print ('event is clear')
    ev.clear()

def start_operate():
    ev.wait()
    while ev.is_set():
        print ('start task')
        x = np.random.randint(1,30)
        time.sleep(1)
        if x == 29:
            print ('True')
    print ('event stop')

t1=threading.Thread(target=flag)
t2=threading.Thread(target=start_operate)

t1.start()
t2.start()


